package com.ming.DaoImp;

import com.ming.Dao.filterDao;
import com.ming.entity.filter;
import com.ming.util.Database;
import com.ming.Dao.*;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/7/30 0030.
 */
public class filterDaoImp extends Database implements filterDao {
    public List<filter> findCaoDan(int id){
        List<filter> list = new ArrayList<filter>();
        Connection con = null;
        PreparedStatement stat = null;
        ResultSet rs = null;
        product_relationDao pdao = new product_relationDaoImp();

        try {
            String sql = "SELECT *from filter WHERE fid = ?";
            con = Database.getConnection();
            stat = con.prepareStatement(sql);
            stat.setInt(1,id);
            rs = stat.executeQuery();
            while(rs.next()){
                filter ca = new filter();
                ca.setFid(rs.getInt("fid"));
                ca.setFilterName(rs.getNString("filterName"));
                ca.setValidTime(rs.getInt("validTime"));
                list.add(ca);
            }


        }catch (Exception e){

        }finally {
            Database.closeConnection(con,stat,rs);
        }

        return list;
    }


}
